/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package cl.zeke.pizzastore.negocio.entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author taller
 */
@Entity
@Table(name = "VENTA_PIZZA")
@NamedQueries({
    @NamedQuery(name = "VentaPizza.findAll", query = "SELECT v FROM VentaPizza v"),
    @NamedQuery(name = "VentaPizza.findByIdVenta", query = "SELECT v FROM VentaPizza v WHERE v.ventaPizzaPK.idVenta = :idVenta"),
    @NamedQuery(name = "VentaPizza.findByIdPizza", query = "SELECT v FROM VentaPizza v WHERE v.ventaPizzaPK.idPizza = :idPizza"),
    @NamedQuery(name = "VentaPizza.findByPrecioUnitario", query = "SELECT v FROM VentaPizza v WHERE v.precioUnitario = :precioUnitario"),
    @NamedQuery(name = "VentaPizza.findByCantidad", query = "SELECT v FROM VentaPizza v WHERE v.cantidad = :cantidad")})
public class VentaPizza implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected VentaPizzaPK ventaPizzaPK;
    @Basic(optional = false)
    @Column(name = "PRECIO_UNITARIO")
    private int precioUnitario;
    @Basic(optional = false)
    @Column(name = "CANTIDAD")
    private int cantidad;
    @JoinColumn(name = "ID_PIZZA", referencedColumnName = "ID_PIZZA", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Pizza pizza;
    @JoinColumn(name = "ID_VENTA", referencedColumnName = "ID_VENTA", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Venta venta;

    public VentaPizza() {
    }

    public VentaPizza(VentaPizzaPK ventaPizzaPK) {
        this.ventaPizzaPK = ventaPizzaPK;
    }

    public VentaPizza(VentaPizzaPK ventaPizzaPK, int precioUnitario, int cantidad) {
        this.ventaPizzaPK = ventaPizzaPK;
        this.precioUnitario = precioUnitario;
        this.cantidad = cantidad;
    }

    public VentaPizza(long idVenta, long idPizza) {
        this.ventaPizzaPK = new VentaPizzaPK(idVenta, idPizza);
    }

    public VentaPizzaPK getVentaPizzaPK() {
        return ventaPizzaPK;
    }

    public void setVentaPizzaPK(VentaPizzaPK ventaPizzaPK) {
        this.ventaPizzaPK = ventaPizzaPK;
    }

    public int getPrecioUnitario() {
        return precioUnitario;
    }

    public void setPrecioUnitario(int precioUnitario) {
        this.precioUnitario = precioUnitario;
    }

    public int getCantidad() {
        return cantidad;
    }

    public void setCantidad(int cantidad) {
        this.cantidad = cantidad;
    }

    public Pizza getPizza() {
        return pizza;
    }

    public void setPizza(Pizza pizza) {
        this.pizza = pizza;
    }

    public Venta getVenta() {
        return venta;
    }

    public void setVenta(Venta venta) {
        this.venta = venta;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (ventaPizzaPK != null ? ventaPizzaPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof VentaPizza)) {
            return false;
        }
        VentaPizza other = (VentaPizza) object;
        if ((this.ventaPizzaPK == null && other.ventaPizzaPK != null) || (this.ventaPizzaPK != null && !this.ventaPizzaPK.equals(other.ventaPizzaPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cl.zeke.pizzastore.negocio.entities.VentaPizza[ ventaPizzaPK=" + ventaPizzaPK + " ]";
    }
    
}
